USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Insert]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Insert record into table [dbo].[MaritalStatus]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Insert]
	/*@MaritalStatus_RowNumber int =Null OUTPUT , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@MaritalStatus_Code varchar(50) =Null  , 
	@MaritalStatus_NameAr varchar(300) =Null  , 
	@MaritalStatus_NameEn varchar(300) =Null  , 
	@MaritalStatus_Notes varchar(max) =Null  , 
	@MaritalStatus_Search varchar(max) =Null  , 
	@MaritalStatus_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[MaritalStatus](/*[MaritalStatus_ID], [MaritalStatus_Code], [MaritalStatus_NameAr], [MaritalStatus_NameEn], [MaritalStatus_Notes], [MaritalStatus_Search]*/)
	VALUES     (/*@MaritalStatus_ID, @MaritalStatus_Code, @MaritalStatus_NameAr, @MaritalStatus_NameEn, @MaritalStatus_Notes, @MaritalStatus_Search*/)

	/*SELECT @MaritalStatus_RowNumber = [MaritalStatus_RowNumber], @MaritalStatus_TimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
    WHERE  ( [MaritalStatus_ID] =@MaritalStatus_ID )
	AND  ( [MaritalStatus_Code] =@MaritalStatus_Code )
	AND  ( [MaritalStatus_NameAr] =@MaritalStatus_NameAr )
	AND  ( [MaritalStatus_NameEn] =@MaritalStatus_NameEn )
	AND  ( [MaritalStatus_Notes] =@MaritalStatus_Notes )
	AND  ( [MaritalStatus_Search] =@MaritalStatus_Search )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-update]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Update record in table [dbo].[MaritalStatus]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-update]
	/*@MaritalStatus_RowNumber int =Null OUTPUT , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@MaritalStatus_Code varchar(50) =Null  , 
	@MaritalStatus_NameAr varchar(300) =Null  , 
	@MaritalStatus_NameEn varchar(300) =Null  , 
	@MaritalStatus_Notes varchar(max) =Null  , 
	@MaritalStatus_Search varchar(max) =Null  , 
	@MaritalStatus_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
    	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)

    IF  @OldTimeStamp = @MaritalStatus_TimeStamp
    BEGIN*/
		Update [dbo].[MaritalStatus] SET 
		/*[MaritalStatus_ID] =@MaritalStatus_ID, 
		[MaritalStatus_Code] =@MaritalStatus_Code, 
		[MaritalStatus_NameAr] =@MaritalStatus_NameAr, 
		[MaritalStatus_NameEn] =@MaritalStatus_NameEn, 
		[MaritalStatus_Notes] =@MaritalStatus_Notes, 
		[MaritalStatus_Search] =@MaritalStatus_Search*/
		/*WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
	/*END*/

	/*SELECT @MaritalStatus_RowNumber = [MaritalStatus_RowNumber], @MaritalStatus_TimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Insert-Update]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Insert OR Update record into table [dbo].[MaritalStatus]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Insert-Update]
	/*@MaritalStatus_RowNumber int =Null OUTPUT , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@MaritalStatus_Code varchar(50) =Null  , 
	@MaritalStatus_NameAr varchar(300) =Null  , 
	@MaritalStatus_NameEn varchar(300) =Null  , 
	@MaritalStatus_Notes varchar(max) =Null  , 
	@MaritalStatus_Search varchar(max) =Null  , 
	@MaritalStatus_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[MaritalStatus] 
					/*WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[MaritalStatus](/*[MaritalStatus_ID], [MaritalStatus_Code], [MaritalStatus_NameAr], [MaritalStatus_NameEn], [MaritalStatus_Notes], [MaritalStatus_Search]*/)
		VALUES     (/*@MaritalStatus_ID, @MaritalStatus_Code, @MaritalStatus_NameAr, @MaritalStatus_NameEn, @MaritalStatus_Notes, @MaritalStatus_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [MaritalStatus_TimeStamp]
		FROM [dbo].[MaritalStatus]
    	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)

		IF  @OldTimeStamp = @MaritalStatus_TimeStamp
		BEGIN*/
			Update [dbo].[MaritalStatus] SET 
			/*[MaritalStatus_ID] =@MaritalStatus_ID, 
			[MaritalStatus_Code] =@MaritalStatus_Code, 
			[MaritalStatus_NameAr] =@MaritalStatus_NameAr, 
			[MaritalStatus_NameEn] =@MaritalStatus_NameEn, 
			[MaritalStatus_Notes] =@MaritalStatus_Notes, 
			[MaritalStatus_Search] =@MaritalStatus_Search*/
			/*WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @MaritalStatus_RowNumber = [MaritalStatus_RowNumber], @MaritalStatus_TimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Delete]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	delete records from table [dbo].[MaritalStatus] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Delete]
	/*@MaritalStatus_RowNumber int =null  , 
	@MaritalStatus_ID uniqueidentifier =null  , 
	@MaritalStatus_Code varchar(50) =null  , 
	@MaritalStatus_NameAr varchar(300) =null  , 
	@MaritalStatus_NameEn varchar(300) =null  , 
	@MaritalStatus_Notes varchar(max) =null  , 
	@MaritalStatus_Search varchar(max) =null  , 
	@MaritalStatus_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[MaritalStatus]
	WHERE /*( [MaritalStatus_RowNumber] = ISNULL(@MaritalStatus_RowNumber, [MaritalStatus_RowNumber]) )
	AND ( [MaritalStatus_ID] = ISNULL(@MaritalStatus_ID, [MaritalStatus_ID]) )
	AND ( [MaritalStatus_Code] like ISNULL(@MaritalStatus_Code, [MaritalStatus_Code]) )
	AND ( [MaritalStatus_NameAr] like ISNULL(@MaritalStatus_NameAr, [MaritalStatus_NameAr]) )
	AND ( [MaritalStatus_NameEn] like ISNULL(@MaritalStatus_NameEn, [MaritalStatus_NameEn]) )
	AND ( [MaritalStatus_Notes] like ISNULL(@MaritalStatus_Notes, [MaritalStatus_Notes]) )
	AND ( [MaritalStatus_Search] like ISNULL(@MaritalStatus_Search, [MaritalStatus_Search]) )
	AND ( [MaritalStatus_TimeStamp] = ISNULL(@MaritalStatus_TimeStamp, [MaritalStatus_TimeStamp]) )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Select]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	select records from table [dbo].[MaritalStatus] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Select]
	/*@MaritalStatus_RowNumber int =null  , 
	@MaritalStatus_ID uniqueidentifier =null  , 
	@MaritalStatus_Code varchar(50) =null  , 
	@MaritalStatus_NameAr varchar(300) =null  , 
	@MaritalStatus_NameEn varchar(300) =null  , 
	@MaritalStatus_Notes varchar(max) =null  , 
	@MaritalStatus_Search varchar(max) =null  , 
	@MaritalStatus_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[MaritalStatus]
	WHERE /*( [MaritalStatus_RowNumber] = ISNULL(@MaritalStatus_RowNumber, [MaritalStatus_RowNumber]) )
	AND ( [MaritalStatus_ID] = ISNULL(@MaritalStatus_ID, [MaritalStatus_ID]) )
	AND ( [MaritalStatus_Code] like ISNULL(@MaritalStatus_Code, [MaritalStatus_Code]) )
	AND ( [MaritalStatus_NameAr] like ISNULL(@MaritalStatus_NameAr, [MaritalStatus_NameAr]) )
	AND ( [MaritalStatus_NameEn] like ISNULL(@MaritalStatus_NameEn, [MaritalStatus_NameEn]) )
	AND ( [MaritalStatus_Notes] like ISNULL(@MaritalStatus_Notes, [MaritalStatus_Notes]) )
	AND ( [MaritalStatus_Search] like ISNULL(@MaritalStatus_Search, [MaritalStatus_Search]) )
	AND ( [MaritalStatus_TimeStamp] = ISNULL(@MaritalStatus_TimeStamp, [MaritalStatus_TimeStamp]) )*/
END
GO
-- =============================================
